# https://www.cnblogs.com/alex-13/p/12016554.html
# https://zhuanlan.zhihu.com/p/127837363
from selenium import webdriver
import time

# 声明浏览器
browser = webdriver.Chrome()

# 找到html文件并打开
Path_name = 'D:/PythonWorkspace/python100/Day50/selenium.html'
browser.get(Path_name)
browser.maximize_window()

# 查找元素并操作
User_name = browser.find_element_by_css_selector('div#signup [name="username"]').send_keys('rabbit')
time.sleep(2)
Pass_word = browser.find_element_by_css_selector('div#signup [name="password"]').send_keys('love')
time.sleep(2)
Confirm_button = browser.find_element_by_css_selector('div#signup .sub').click()
time.sleep(3)

success = browser.find_element_by_css_selector('div#signup p')
text = success.text
if text == "注册成功":
    print("注册成功")
else:
    print("注册失败")

time.sleep(5)

# 关闭浏览器
browser.quit()